<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core " %>
<%@include file="./../../../taglibs.jsp"%>
<html lang="en">
	<head>
		<%@include file="./../../../header.jsp"%>
		<script src="/app/static/plugins/kindeditor/kindeditor-all-min.js"></script>
	</head>
	<body class="body">		
		<a href="javascript:history.go(-1);" class="layui-btn">返回</a>	
		<form class="layui-form layui-form-labelw100" style="width: 500px;margin-top: 30px;">
			<div class="layui-form-item">
				<label class="layui-form-label"><i class="must_star">*</i>标题</label>
				<div class="layui-input-block">
					<input type="text" required lay-verify="required" placeholder="" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><i class="must_star">*</i>所属分类</label>
				<div class="layui-input-block">
					<select>
				        <option value="">超级管理员</option>
				        <option value="0">一级账户</option>
				        <option value="1">二级账户</option>
				        <option value="2">三级账户</option>
				        <option value="3">其他账户</option>
			      	</select>
				</div>
			</div>	
			<div class="layui-form-item">
				<label class="layui-form-label"><i class="must_star">*</i>选择时间</label>
				<div class="layui-input-block">
					<input type="text" id="publishTime" required lay-verify="required" placeholder="" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><i class="must_star">*</i>排序</label>
				<div class="layui-input-block">
					<input type="number" required lay-verify="required" placeholder="" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><i class="must_star">*</i>文章内容</label>
				<div class="layui-input-block">
					<textarea class="layui-textarea" id="articleContent"></textarea>
				</div>
			</div>
			<div class="layui-form-item">
			    <label class="layui-form-label">发布状态</label>
			    <div class="layui-input-block">
			      <input type="radio" name="status" value="0" title="正式">
			      <input type="radio" name="status" value="1" title="草稿" checked>
			    </div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button type="reset" class="layui-btn layui-btn-primary">取消</button>
					<button class="layui-btn" lay-submit lay-filter="formSubmit">提交</button>
				</div>
			</div>
		</form>

		<script type="text/javascript">
		
			var form = layui.form,
				layer = layui.layer,
				layedit = layui.layedit,
				laydate = layui.laydate
				form.render()

				laydate.render({
			       elem: '#publishTime' //指定元素
			     });
			
				//编辑器初始化
				KindEditor.ready(function(K) {
	                window.editor = K.create('#articleContent',{
	                	uploadJson : '../jsp/upload_json.jsp',
						fileManagerJson : '../jsp/file_manager_json.jsp',
						allowFileManager : true,
						height:500
	                });
		        });
			
				//取得编辑器内容
		        function getEditorData() {
		            return editor.html();
		        }
		
		
				form.on('submit(formSubmit)', function(data){
				    var formData = JSON.stringify(data.field);
				    $.ajax({
				    	type:"post",
				    	url:"",
				    	async:true,
				    	data:formData,
				    	success:function(res){
				    		if(res==0){			//失败
				    			layer.msg('创建失败。。', {icon: 5});
				    		}else if(res==1){	//成功
				    			layer.msg('创建成功。。', {icon: 6});
				    			window.location.reload()
				    		}
				    	},
				    	error:function(){
				    		layer.msg('创建失败。。', {icon: 5});
				    	}
				    });
				    return false;
				});

			
		</script>
	</body>
</html>


